<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
// load base class if needed
require_once( APPPATH . 'controllers/base/OperatorBase.php' );

class project extends ApplicationBase { 
    // constructor
    public function __construct() {
        parent::__construct();
        // load model
        $this->load->model('m_project');
        $this->load->model('m_perusahaan');
        $this->load->model('m_klien'); 
        $this->load->model('m_account');  
        // load library
        $this->load->library('tnotification');
        $this->load->library('pagination');
        // load helpers
        
        // load js
        $this->smarty->load_javascript("resource/js/jquery/jquery-ui-1.9.2.custom.min.js");
        $this->smarty->load_style("jquery.ui/redmond/jquery-ui-1.8.13.custom.css");
    }

    // welcome administrator
    public function index() {
        // set template content
        $this->smarty->assign("template_content", "task/project/list.html");
        /* start of pagination --------------------- */
        // pagination
        $config['base_url'] = site_url("task/project/index/");
        $config['total_rows'] = $this->m_project->get_count_all_project_by_pm($this->com_user['user_id']);
        $config['uri_segment'] = 4;
        $config['per_page'] = 10;
        $this->pagination->initialize($config);
        $pagination['data'] = $this->pagination->create_links();
        // pagination attribute
        $start = $this->uri->segment(4, 0) + 1;
        $end = $this->uri->segment(4, 0) + $config['per_page'];
        $end = (($end > $config['total_rows']) ? $config['total_rows'] : $end);
        $pagination['start'] = ($config['total_rows'] == 0) ? 0 : $start;
        $pagination['end'] = $end;
        $pagination['total'] = $config['total_rows'];
        // pagination assign value
        $this->smarty->assign("pagination", $pagination);
        $this->smarty->assign("no", $start);
        /* end of pagination ---------------------- */
        // get data
        $params = array($this->com_user['user_id'], ($start - 1), $config['per_page']);
        $this->smarty->assign("rs_id", $this->m_project->get_all_project_pagination_by_pm($params));
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    } 
    
    public function detail($project_id) { 
        // $this->_set_page_rule("R");
        // set template content
        $this->smarty->assign("template_content", "task/project/detail.html");
        
        // notification
        $this->tnotification->display_notification();
        $this->tnotification->display_last_field();
        // output
        parent::display();
    }
        
} 